//
//  GFZtViewController.m
//  Qyer
//
//  Created by dlios on 15/10/23.
//  Copyright (c) 2015年 GF. All rights reserved.
//

#import "GFZtViewController.h"

@interface GFZtViewController ()<UITableViewDataSource, UITableViewDelegate>

@end

@implementation GFZtViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    _tableArray = [NSMutableArray array];
    _table = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT) style:UITableViewStylePlain];
    [_table setDelegate:self];
    [_table setDataSource:self];
    [self.view addSubview:_table];
    [self getAfn];
}

- (void)getAfn{
    [AFN getdataWithString:_afnString block:^(id block) {
        for (NSDictionary *dic in block) {
            GFJnModel *model = [GFJnModel modelWithDictionary:dic];
            [_tableArray addObject:model];
        }
        [_table reloadData];
    } BLOCK:^(id BLOCK) {
        
    }];
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return _tableArray.count;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 230 * HEIGHT;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *guoFeng = @"cell";
    GFTbTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:guoFeng];
    if (!cell) {
        cell = [[GFTbTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:guoFeng];
    }
    GFJnModel *model = [_tableArray objectAtIndex:indexPath.row];
    [cell getjnmodel:model];
    return cell;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
